package com.jsfcompref.solutech.backing;


import com.eCommerce.corecontract.dto.CategorieDTO;
import com.eCommerce.corecontract.exception.EcommerceException;
import com.eCommerce.server.corebackend.util.BackEndConstants;
import com.eCommercecorecontract.svco.ICategorieSVCO;
import com.eCommercecorecontract.svco.SVCOFinder;
import com.ecommerceWeb.common.ServiceFinder;
import java.util.List;

import javax.faces.component.UIData;
import javax.faces.context.FacesContext;

public class Catalogue {
	
	

	 public Catalogue() {
		super();
		// TODO Auto-generated constructor stub
	}
	 
	private UIData data = null;

	public UIData getData() {
		return data;
	}

	public void setData(UIData data) {
		this.data = data;
	}

	public List getCategories()
	  {		
			List cats = null;
			try {
				SVCOFinder sVCOFinder=(SVCOFinder) ServiceFinder.findBean("SVCOFinder");
				ICategorieSVCO categorieSVCO=(ICategorieSVCO)sVCOFinder.get(BackEndConstants.SVCO_CATEGORIE);
				
				cats = categorieSVCO.listerCategorie();
			} catch (EcommerceException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}


	  return cats;
	  }
	public String getComposantsAction(){
		
		CategorieDTO selectedCategory = (CategorieDTO) this.getData().getRowData();
		FacesContext ctx = FacesContext.getCurrentInstance();
		ctx.getExternalContext().getSessionMap().put("GetCategorie", selectedCategory);
		
		return "composants";
	}
 
}
